// Copyright (c) 2020 Presto Labs Pte. Ltd.
// Author: leon

#pragma once

#include <iomanip>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#include "coin2/base/time.h"
#include "coin2/exchange/feed.pb.h"

struct UnderlyingAsset {
  std::string symbol_or_currency;
  double amount;
  UnderlyingAsset(std::string&& s, double a)
      : symbol_or_currency(std::move(s)),
        amount(a) {}
};

struct Nav {
  int64_t timestamp;
  double actual_leverage;
  double nav;
  double outstanding;
  std::vector<UnderlyingAsset> basket;

  void Clear() {
    timestamp = 0;
    actual_leverage = 0;
    nav = 0;
    outstanding = 0;
    basket.clear();
  }
};

inline std::ostream& operator<<(
    std::ostream& os,
    const Nav& nav) {
  os << "NAV ";
  os << "(actual_leverage=";
  os << std::setw(15);
  os << nav.actual_leverage;
  os << ",nav=";
  os << std::setw(15);
  os << nav.nav;
  os << ",outstanding=";
  os << std::setw(15);
  os << nav.outstanding;
  for (auto& ua : nav.basket) {
    os << ",symbol_or_currency=";
    os << std::setw(15);
    os << ua.symbol_or_currency;
    os << ",amount=";
    os << std::setw(15);
    os << ua.amount;
  }
  os << ")";
  return os;
}
